package com.ling.pl.autoproject.definition.service;

import com.ling.pl.autoproject.definition.model.ProjectEntity;
import com.ling.pl.autoproject.definition.model.ProjectVO;
import com.ling.pl.core.commons.utils.reflect.ReflectUtils;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author bo.wang
 */
@Component(ProjectService.BEAN_ID)
public class ProjectService extends BaseProjectService {

    protected List<ProjectVO> convertProjectToVO(List<ProjectEntity> models) {
        List<ProjectVO> result = new ArrayList<ProjectVO>();
        for (ProjectEntity initiation : models) {
            ProjectVO inparam = convertProjectToVO(initiation);
            result.add(inparam);
        }
        return result;
    }

    public ProjectVO convertProjectToVO(ProjectEntity model) {
        ProjectVO inparam = new ProjectVO();
        ReflectUtils.copyProperties(model, inparam);
        return inparam;
    }

    public ProjectEntity convertProjectVOToEntity(ProjectVO vo) {
        ProjectEntity entity = new ProjectEntity();
        ReflectUtils.copyProperties(vo, entity);
        return entity;
    }

}

